-
Notifications
You must be signed in to change notification settings - Fork 737
[gh/wf/linux.yml] allow workflow cancellation #4030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8d4cafa to
f94535f
Compare
f91d132 to
378e167
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4030 +/- ##
=======================================
Coverage 89.53% 89.53%
=======================================
Files 260 260
Lines 14741 14741
=======================================
Hits 13198 13198
Misses 1543 1543 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7016758 to
0ca7ffb
Compare
|
Good, this addresses #4048 now too. |
Github's workflow cancellation is a real headache. The matrix part of the job seems resistant to every kind of cancellation request I've tried, except for force cancel. I'm still investigating why that is. I'll add some trace steps to jobs to see whether the cancellation signals (SIGINT, SIGTERM, etc.) are reaching to the steps at all. |
In case anyone needs I'm using the following bash functions to kill workflows forcefully: github-kill-workflow(){
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$1/actions/runs/$2/force-cancel
}
github-kill-workflow-by-url() {
url="$1"
repo=$(echo "$url" | awk -F'[/?]' '{print $4 "/" $5}')
run_id=$(echo "$url" | awk -F'[/?]' '{print $8}')
echo "repo: $repo"
echo "run_id: $run_id"
github-kill-workflow $repo $run_id
}Include them in your .bashrc, then use it like github-kill-workflow-by-url https://github.com/canonical/multipass/actions/runs/14502559305?pr=4030 |
Finally figured out why that is. if: |
${{
success()
|| needs.Lint.result == 'skipped'
|| ( needs.Lint.result == 'failure'
&& github.event_name == 'pull_request' )
}}The BuildAndTest is cancellable after commenting out the precondition.
So, this expression somehow evaluates to true on re-check, even with |
fc3b1c9 to
4b1ccb8
Compare
allow in progress workflows to be cancelled when an external event requests, (e.g. the workflow run has been superseded with a new commit). Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
https://docs.github.com/en/enterprise-cloud@latest/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
also replace instances of !failed() with success(). Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
4b1ccb8 to
566db19
Compare
|
@ricab finally, everything works as it should. A new push cancels the previous runs, and the "cancel workflow" button works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job Mustafa, thanks! 2 tiny things inline, but pre-approving.
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
| if: ${{ !cancelled() && | ||
| ( | ||
| success() || | ||
| needs.Lint.result == 'skipped' || | ||
| ( | ||
| needs.Lint.result == 'failure' && | ||
| github.event_name == 'pull_request' | ||
| ) | ||
| ) | ||
| }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a lot of line splitting now, but ok...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, LGTM, thanks again @xmkg!
|
I would just like to get @sharder996's review on this one if possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I think it looks good. Biggest thing is that Github will group CI runs by head-ref now.
Allow in-progress workflows to be canceled when an external event requests them (e.g., the workflow run has been superseded with a new commit).
MULTI-1939